<%@ page import="com.dmp.onlinestore.model.dto.ProductBean" %>
<%@ page import="java.util.List" %>
<%@ page import="com.dmp.onlinestore.view.base.ViewAddressFactory" %>
<%@ page import="com.dmp.onlinestore.view.base.ViewDefs" %>
<%@ page import="com.dmp.onlinestore.controller.ActionHandlerGetProducts" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Welcome</title>
<LINK REL=STYLESHEET
      HREF="JSP-Styles.css"
      TYPE="text/css">
</head>
<body>
<%
//@SuppressWarnings("unchecked");
// List of products.
String prodAttr = ViewDefs.ATTR_PRODUCT_LIST;
List<ProductBean> productList = (List<ProductBean>) request.getAttribute(prodAttr);
List<String> indicesList = (List<String>) request.getAttribute(ViewDefs.ATTR_INDEX_LIST);
String actionField = ViewDefs.REQUEST_FIELD_ACTION;
String actionGetProducts = ViewDefs.ACTION_GET_PRODUCTS;
String actionPaging = ActionHandlerGetProducts.PARM_PAGING;
String pageNext = ActionHandlerGetProducts.PAGING_NEXT;
String pagePrev = ActionHandlerGetProducts.PAGING_PREV;
String pageGoto = ActionHandlerGetProducts.PAGING_GOTO_PAGE;
String gotoTarget = ActionHandlerGetProducts.GOTO_TARGET;
String setPageSize = ActionHandlerGetProducts.PAGING_PAGE_SIZE;
String newSize = ActionHandlerGetProducts.PAGE_NEW_SIZE;
String currentViewRange = (String) request.getAttribute(ViewDefs.ATTR_CURR_RANGE);
//String actionField = ViewUtilities.REQUEST_FIELD_ACTION;
%>
<%@ include file="/WEB-INF/views/no_frills/StandardHeader.jsp" %>
<h1>Welcome to the DMP!!</h1>
<p>List of products...
<p>
Set new page size: 
<a href="<%=contextPath%><%=servletMapping%>?<%=actionField%>=<%=actionGetProducts%>&<%=actionPaging%>=<%=setPageSize%>&<%=newSize%>=5">5</a>
<a href="<%=contextPath%><%=servletMapping%>?<%=actionField%>=<%=actionGetProducts%>&<%=actionPaging%>=<%=setPageSize%>&<%=newSize%>=10">10</a>
<a href="<%=contextPath%><%=servletMapping%>?<%=actionField%>=<%=actionGetProducts%>&<%=actionPaging%>=<%=setPageSize%>&<%=newSize%>=15">15</a>
<a href="<%=contextPath%><%=servletMapping%>?<%=actionField%>=<%=actionGetProducts%>&<%=actionPaging%>=<%=setPageSize%>&<%=newSize%>=20">20</a>
<p>
Currently viewing: <%=currentViewRange%>
<p>
<a href="<%=contextPath%><%=servletMapping%>?<%=actionField%>=<%=actionGetProducts%>&<%=actionPaging%>=<%=pagePrev%>">Prev</a>
<%
for (int i=0 ; i < indicesList.size(); i++) {
	int pageNum = i+1;
	String range = indicesList.get(i);
	//System.out.println("Page #" + pageNum + " is >>" + range + "<<");
%>
<a href="<%=contextPath%><%=servletMapping%>?<%=actionField%>=<%=actionGetProducts%>&<%=actionPaging%>=<%=pageGoto%>&<%=gotoTarget%>=<%=pageNum%>"><%=range%></a>
<%
}
%>
<a href="<%=contextPath%><%=servletMapping%>?<%=actionField%>=<%=actionGetProducts%>&<%=actionPaging%>=<%=pageNext%>">Next</a>
<ul>
<%
for (ProductBean product : productList) {
	String prodStr = product.toString();
%>
<li>
<ul>
<li>Id: <%=product.getId()%>
<li>Name: <%=product.getName()%>
<li>Category: <%=product.getCategory()%>
<li>Subcategory: <%=product.getSubcategory()%>
<li>Price: <%=product.getPrice()%>
<li>Rating: <%=product.getRating()%>
<li>Short Desc: <%=product.getDescShort()%>
<li>Long Desc: <%=product.getDescLong()%>
<li>Performers: <%=product.getPerformers()%>
</ul>
</li>
<%--
<li><%=name%> <a href="<%=contextPath%>?<%=actionField%>=<%=actionGetAddress%>&id=<%=person.getId()%>">Addresses</a>
--%>
<%
} // for
%>
</ul>
<p>
<a href="<%=contextPath%><%=servletMapping%>?<%=actionField%>=<%=actionGetProducts%>&<%=actionPaging%>=<%=pagePrev%>">Prev</a>
<%
for (int i=0 ; i < indicesList.size(); i++) {
	int pageNum = i+1;
	String range = indicesList.get(i);
	//System.out.println("Page #" + pageNum + " is >>" + range + "<<");
%>
<a href="<%=contextPath%><%=servletMapping%>?<%=actionField%>=<%=actionGetProducts%>&<%=actionPaging%>=<%=pageGoto%>&<%=gotoTarget%>=<%=pageNum%>"><%=range%></a>
<%
}
%>
<a href="<%=contextPath%><%=servletMapping%>?<%=actionField%>=<%=actionGetProducts%>&<%=actionPaging%>=<%=pageNext%>">Next</a>
<p>
<%--
<a href="<%=contextPath%>?<%=actionField%>=<%=actionCreateAccount%>">Create a new account.</a>
--%>
</body>
</html>

